#ifndef RTPHANDLER_H
#define RTPHANDLER_H

#include <QHostAddress>
#include <QObject>
#include <QUdpSocket>

struct RTPHeader
{
    uint8_t version:2;
    uint8_t padding:1;
    uint8_t extension:1;
    uint8_t csrcCount:4;
    uint8_t marker:1;
    uint8_t payloadType:8;
    uint16_t sequenceNumber;
    uint32_t timestamp;
    uint32_t ssrc;
};

class RTPHandler : public QObject
{
    Q_OBJECT
public:
    explicit RTPHandler(const QHostAddress &remoteAddress, quint16 remotePort,
                        quint16 localPort, QObject *parent = nullptr);
    ~RTPHandler();

    void sendRTPPacket(const QByteArray &payload);
signals:
    void rtpPacketReceived(const QByteArray &payload);

private slots:
    void processPendingDatagrams();

private:
    QUdpSocket *udpSocket;
    QHostAddress remoteAddress;
    quint16 remotePort;
    uint16_t sequenceNumber;
    uint32_t timestamp;
    uint32_t ssrc;

};

#endif // RTPHANDLER_H
